#include <gtk/gtk.h>
#include "zmenu.h"
#include "zcontainer.h"

static gboolean on_quit(GtkWidget *widget,
        		GdkEvent  *event,
                        gpointer   data)
{
    ZContainer *zContainer;
    zContainer = (ZContainer *)data;
    closeAllConnection_ZServer(getZServer_ZContainer(zContainer));
  return FALSE;
  (void)widget;
  (void)event;
}

int main(int argc, char **argv) {
	GtkWidget *window;
	GtkWidget *vbox;
	ZContainer *zContainer;

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(GTK_WINDOW(window), 700, 600);
	gtk_container_set_border_width(GTK_CONTAINER(window), 0);

	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add(GTK_CONTAINER(window), vbox);
	zContainer = create_ZContainer();
	gtk_box_pack_start (GTK_BOX (vbox), createMenu_Menu(zContainer), FALSE, FALSE, 0);

	gtk_box_pack_start (GTK_BOX (vbox), getContainer_ZContainer(zContainer), TRUE, TRUE, 1);
	g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), zContainer);

	g_signal_connect(window, "delete-event", G_CALLBACK(on_quit), zContainer);

	gtk_widget_show_all(window);

	gtk_main();

	return 0;
}
